using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Unbound.Tests.Unbinding.Configuration
{
/* I've traditionally used an extension method like this.  blah.ToHttpDictionary()
 * Pretty useful sometimes. 
 * If you need a custom unbinder, implement ISpecificValueUnbinder and plug it in to the CustomUnbinders.
 * A custom unbinder would take a specific value from an object - one that your model binding
 * infrastructure would use to recreate your object.  This is used in our system for entities and 
 * enumeration classes.
 */

	public static class UnboundExtension
	{
		public static IDictionary<string, object> ToHttpDictionary(this object request, string prefix)
		{
			return new Unbound.Unbinder().Unbind(request, prefix);
		}

		public static IDictionary<string, object> ToHttpDictionary(this object request)
		{
			return new Unbound.Unbinder().Unbind(request);
		}

		public static IDictionary<string, object> ToHttpDictionary<T>(this T request, Expression<Func<T, object>> propertyToSkip)
		{
			return new Unbound.Unbinder().Unbind(o => o.Source(request).SkipProperty(propertyToSkip));
		}

		public static IDictionary<string, object> ToHttpDictionary<T>(this T request, params Expression<Func<T, object>>[] propertiesToSkip)
		{
			return new Unbound.Unbinder().Unbind(o => o.Source(request).SkipProperties(propertiesToSkip));
		}
	}
}